package com.xiaohang.springstudy.chapter1.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Swagger静态资源映射
 * 配合使用org.webjars.swagger-ui.jar
 * /META-INF/resources/webjars/swagger-ui/3.0.17/index.html
 * http://localhost:8080/index.html?url=/v2/api-docs
 */
@Configuration
public class MySwaggerWebMvcConfg implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("index.html")
                .addResourceLocations("classpath:/META-INF/resources/webjars/swagger-ui/3.0.17/");
        registry.addResourceHandler("/**")
                .addResourceLocations("classpath:/META-INF/resources/webjars/swagger-ui/3.0.17/");
    }
}
